﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;

namespace QFlow.Data
{
    public static class StockableProductExtenstion
    {
        public static bool CheckNewGlobalBarcode(this Table<StockableProduct> queriable, string barcode)
        {
            var result = from product in queriable
                         group product by product.GlobalBarcode into g
                         where g.Key == barcode
                         select g.Count();
            if (result.Count() == 0)
                return true;
            else return result.First() == 0;
        }

        public static string GetBarcode(this Table<StockableProduct> queriable)
        {
            return DateTime.Now.ToString("MMddyyyyhhmms");
        }
    }
}
